package com.prs.crm.service.crm.impl;

import java.io.File;
import java.util.Collection;

import com.prs.crm.context.FileUtil;
import com.prs.crm.dao.crm.MeetReportCritiqueDao;
import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.crm.MeetReport;
import com.prs.crm.domain.crm.MeetReportCritique;
import com.prs.crm.domain.oa.Notice;
import com.prs.crm.service.crm.MeetReportCritiqueService;
import com.prs.crm.service.impl.BaseServiceImpl;
import com.prs.crm.service.oa.NoticeService;

public class MeetReportCritiqueServiceImpl extends BaseServiceImpl<MeetReportCritique,MeetReportCritiqueDao> implements MeetReportCritiqueService{
	private NoticeService noticeService;
	
	@Override
	public void submitMeetReportCritique(MeetReportCritique meetReportCritique,
			File file, String fileName) {
		// TODO Auto-generated method stub
		Attachment attach = FileUtil.getInstance().createAttach(file, fileName);
		if(attach != null) {
			meetReportCritique.setAttach(attach);
		}
		this.getDao().save(meetReportCritique);
		
		String msg = "您的"+meetReportCritique.getMeetReport().getRecordTime()+"的"+meetReportCritique.getMeetReport().getCustomer().getName()+"的约见报告已被点评，请查看";
		Notice notice = new Notice();
		notice.setTitle("约见点评");
		notice.setContent(msg);
		
		this.getNoticeService().sendNotice(notice, meetReportCritique.getMeetReport().getRecorder());
	}

	@Override
	public Collection<MeetReportCritique> getMeetReportCritique(
			MeetReport meetReport) {
		// TODO Auto-generated method stub
		return this.getDao().getMeetReportCritique(meetReport);
	}

	public void setNoticeService(NoticeService noticeService) {
		this.noticeService = noticeService;
	}

	public NoticeService getNoticeService() {
		return noticeService;
	}

}
